package com.hanny.ffmpeg

import android.os.Bundle
import android.view.View
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.hanny.ffmpeg.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {

    private lateinit var binding: ActivityMainBinding

    private var textView: TextView? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        binding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(binding.root)
        textView = findViewById<TextView>(R.id.textview)
    }

    fun format(view: View?) {
        textView?.setText(avformatinfo())
    }

    fun codec(view: View?) {
        textView?.setText(avcodecinfo())
    }

    fun filter(view: View?) {
        textView?.setText(avfilterinfo())
    }

    fun config(view: View?) {
        textView?.setText(configurationinfo())
    }

    /**
     * A native method that is implemented by the 'native-lib' native library,
     * which is packaged with this application.
     */
    external fun stringFromJNI(): String

    //JNI
    external fun avformatinfo(): String?
    external fun avcodecinfo(): String?
    external fun avfilterinfo(): String?
    external fun configurationinfo(): String?

    companion object {
        // Used to load the 'native-lib' library on application startup.
        init {
            System.loadLibrary("native-lib")
        }
    }
}